package hao.d02;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.util.*;

public class StudentTest {
    public static void main(String[] args) throws Exception{
        List<Student> list=new ArrayList<>();
        for (int i = 1; i <=68 ; i++) {
            Random rd=new Random();
            int chengji;
            int studentid;
            String str;
            if (i<10){
                chengji=rd.nextInt(51)+50;
                studentid=180000+i;
                str="同学:"+0+i;
            }else {
                chengji=rd.nextInt(51)+50;
                studentid=180000+i;
                str="同学:"+i;
            }
            Student student=new Student(studentid,str,chengji);
            list.add(student);
        }
        Collections.sort(list);
        BufferedWriter bw=new BufferedWriter(new FileWriter("src/com/student.txt"));
        Iterator<Student> it=list.iterator();
        while (it.hasNext()){
            Student s=it.next();
            String s1="学号:"+s.getId()+" "+"姓名:"+s.getName()+" "+"成绩："+s.getScroce();
            bw.write(s1+"\r\n");
        }
        bw.close();
    }
}